package com.pafcio.dde.client;

import java.util.HashSet;
import java.util.Set;

import com.neva.DdeClientTransactionEvent;

public class SimpleCapturingListener extends AbstractListener implements CapturingListener{
	
	Set<Observer<DdeClientTransactionEvent>> observers = new HashSet<Observer<DdeClientTransactionEvent>>(); 
	
	@Override
	public void onAdviseData(DdeClientTransactionEvent event) {
		notify(event);
	}
	
	@Override
	public synchronized void attach(Observer<DdeClientTransactionEvent> observer) {
		observers.add(observer);
	}

	@Override
	public void notify(DdeClientTransactionEvent event) {
		for (Observer<DdeClientTransactionEvent> observer : observers) {
			observer.update(event);
		}
	}

	@Override
	public synchronized void detach(Observer<DdeClientTransactionEvent> observer) {
		observers.remove(observer);
	}
}
